﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Doo.WebUI
{
    /// <summary>
    /// 可配置控件面板
    /// </summary>
    public class WidgetConfigControl : WebControl
    {
        protected Control widget;

        public WidgetConfigControl(Control widget)
        {
            this.widget = widget;
            this.Controls.Add(widget);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            #region <div> root

            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            #region <div> header

            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            // <span> title
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(widget.GetType().Name);
            writer.RenderEndTag();
            // <a> config
            writer.AddAttribute(HtmlTextWriterAttribute.Href, "javascript:void(0)");
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("Doo.PageBuilder.EditorPanel.showConfig('{0}',this);", widget.GetType().FullName));
            writer.AddAttribute("WP", "{}");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write("配置");
            writer.RenderEndTag();

            writer.RenderEndTag();

            #endregion

            #region <div> body

            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            this.RenderChildren(writer);

            writer.RenderEndTag();

            #endregion

            writer.RenderEndTag();

            #endregion
        }
    }
}
